
<%--
    Document   : busqueda_personalizada_lineas
    Created on : 10-27-2010, 07:36:01 PM
    Author     : Dada
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<HTML>
<HEAD>
<TITLE>Busqueda personalizada lineas</TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">

<link rel="stylesheet" type="text/css" href="resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="fileuploadfield.css"/>
<script type="text/javascript" src="javascript/ext-base.js"></script>
<script type="text/javascript" src="javascript/ext-all.js"></script>

<script type="text/javascript">
<!--
function  clickReporte_Abonado(){
            var hiddenAction=document.getElementById("action");
            hiddenAction.value="reporte_abonado";
        }

        function  clickCrear_Abonado(){
            var hiddenAction=document.getElementById("action");
            hiddenAction.value="crear_abonado";
        }
		function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		butt_01_over = newImage("images/butt_01-over.jpg");
		butt_02_over = newImage("images/butt_02-over.jpg");
		butt_03_over = newImage("images/butt_03-over.jpg");
		butt_04_over = newImage("images/butt_04-over.jpg");
		butt_05_over = newImage("images/butt_05-over.jpg");
		butt_06_over = newImage("images/butt_06-over.jpg");
		preloadFlag = true;
	}}

function MM_popupMsg(msg) { //v1.0
  alert(msg);
}


 var dataStoreLineas;
 var checkBoxSelMod;
    Ext.onReady(function(){

        /*Ahora se cargan los stores del segundo Panel: el de resultados de la busqueda*/

        var urlLineas="CampanaServlet?action=listaGrillaLineas";

        var gridLineaReader = new Ext.data.JsonReader({ root: 'data',
            totalProperty: 'totalCount',
            fields: [
                { name: 'idLinea' },
                { name: 'numero' },
                { name: 'nombreTipoLinea' },
                { name: 'nombreAbonado' },
                { name: 'nombreDep' },
                { name: 'antigua' },
                { name: 'nombreProv' },
                { name: 'nombreDist' }

            ]});

        dataStoreLineas = new Ext.data.Store({
            url: urlLineas,
            remoteSort: true,
            reader: gridLineaReader
        });



        dataStoreLineas.on('beforeload', function(store,options) {
                var filtrosBusqueda= {'idCampana' : document.getElementById("idCampana").value };

                Ext.apply(options.params,filtrosBusqueda);
         });

        var pagingBar = new Ext.PagingToolbar({
            pageSize: 20,
            store: dataStoreLineas,
            displayInfo: true,
            displayMsg: 'Mostrando Lineas {0} - {1} de {2}'
        });

        checkBoxSelMod = new Ext.grid.CheckboxSelectionModel( {
        listeners:{
        rowselect : function( selectionModel, rowIndex, record){
            var selectedRows = selectionModel.getSelections();
            var cadenaHidden="";
			if( selectedRows.length > 0){
                for( var i = 0; i < selectedRows.length; i++) {
                    if (i!=0){
                        cadenaHidden=cadenaHidden+",";
                    }
                    cadenaHidden=cadenaHidden+selectedRows[i].data.idLinea;
                }
            }

            document.getElementById("lineasHidden").value=cadenaHidden;
            // More code related to deselection of a chekbox
            },
        rowdeselect: function( selectionModel, rowIndex, record){
            var selectedRows = selectionModel.getSelections();
            var cadenaHidden="";
            if( selectedRows.length > 0){
                for( var i = 0; i < selectedRows.length; i++) {
                    if (i!=0){
                        cadenaHidden=cadenaHidden+",";
                    }
                    cadenaHidden=cadenaHidden+selectedRows[i].data.idLinea;
                }
            }
            document.getElementById("lineasHidden").value=cadenaHidden;
            // More code related to deselection of a chekbox
            }
        }
        });

        var gridLineas=new Ext.grid.GridPanel({
            store: dataStoreLineas,
            columns: [
                checkBoxSelMod,
                {
                    header: 'Numero',dataIndex:'numero',width:100,renderer: function(value, metaData, record, rowIndex, colIndex, store) {
                                metaData.css = 'multilineColumn'; return value;

                            }
                },
                {
                    header: 'Tipo Linea', dataIndex:'nombreTipoLinea',width:40,renderer: function(value, metaData, record, rowIndex, colIndex, store) {
                                metaData.css = 'multilineColumn'; return value;
                            }
                },
                {
                    header: 'Departamento', dataIndex:'nombreDep',width:50,renderer: function(value, metaData, record, rowIndex, colIndex, store) {
                                metaData.css = 'multilineColumn'; return value;
                            }
                },
                {
                    header: 'Provincia', dataIndex:'nombreProv',width:50,renderer: function(value, metaData, record, rowIndex, colIndex, store) {
                                metaData.css = 'multilineColumn'; return value;
                            }
                },
                {
                    header: 'Distrito', dataIndex:'nombreDist',width:50,renderer: function(value, metaData, record, rowIndex, colIndex, store) {
                                metaData.css = 'multilineColumn'; return value;
                            }
                }
            ],
            bbar: pagingBar,
            selModel : checkBoxSelMod,
            loadMask: true,
            frame: false,
            viewConfig: {
              forceFit: true
            }
        });

        var panelGrid=new Ext.Panel({
            width:850,
            height:480,
            layout: 'fit',
            items: [gridLineas],
            autoScroll:true
        });

         var panelBusqueda = new Ext.FormPanel
         ({
                    renderTo: 'panelBusquedaLineas',
                    layout: 'anchor',
                    frame:true,
                    monitorValid:true,
                    title: 'Resultados de la Busqueda',
                    width: 850,
                    items: [panelGrid]
         });

        /*
        dataStoreLineas.load({params: {start: 0, limit:10},
        callback:function(){
            var cantidad=dataStoreLineas.getTotalCount();
            var registro;
            var arreglo=new Array();
            var cant=0;
            cantidad=cantidad>10?10:cantidad;
            for (i=0;i<cantidad;i++){
                registro=dataStoreLineas.getAt(i);
                if (registro.data.antigua==true){
                    arreglo[cant++]=i;
                }
            }
            checkBoxSelMod.selectRows(arreglo);

        }});
*/
        dataStoreLineas.on("load",function(start,limit){

            var cantidad=dataStoreLineas.getTotalCount();
            var registro;
            var arreglo=new Array();
            var cant=0;
            cantidad=cantidad>20?20:cantidad;
            for (i=0;i<cantidad;i++){
                registro=dataStoreLineas.getAt(i);
                if (registro.data.antigua==true){
                    arreglo[cant++]=i;
                }
            }
            checkBoxSelMod.selectRows(arreglo);
        });
         dataStoreLineas.load({params: {start: 0, limit:20}});


   });
   /*Fin del EXT ON READY*/


//-->
</script>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>

<link href="general.css" rel="stylesheet" type="text/css">
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css">
<link href="SpryAssets/SpryMenuBarVertical.css" rel="stylesheet" type="text/css">

</HEAD>
<BODY BGCOLOR=#133F54 ONLOAD="preloadImages();" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<div align="center">
  <TABLE WIDTH=1000 BORDER=1 CELLPADDING=0 CELLSPACING=0>
    <TR>
      <TD width="178" height="218" align="center" valign="middle" class="logo"><p><strong>Chasqui-soft</strong></p>
      <p><img src="images/defaultlogo.gif" width="48" height="48" alt="logo"></p></TD>
      <TD width="1584" align="left" valign="top"><img src="images/callcenter_banner.jpg" width="1009" height="216" alt="banner"></TD>
    </TR>
    <TR>

      <TD height="152"><img src="images/info_area.jpg" alt="back" width=178 height=270></TD>
      <TD rowspan="3" align="center" valign="top">
          <table width="1000" height="536" border="0" cellspacing="0">
            <tr>
          <td width="1000" height="536" align="center" valign="top" scope="col"><p>&nbsp;</p>
            <p>&nbsp;</p>
            <p class="Titlulos_General">B&uacute;squeda Personalizada de L&iacute;neas</p>
            <p class="Titlulos_General">&nbsp;</p>
            <p class="Titlulos_General"><img src="images/t_19.jpg" width="500" height="2" alt="serparador"></p>
            <p class="Titlulos_General">&nbsp;</p>

            <table width="648" height="36" border="0" cellspacing="0">
                                      <tr>
                                        <th width="547" scope="col"><span class="texto">Buscar por: </span></th>
                                      </tr>
             </table>
             <!--table width="651" height="122" border="0">
<form method="post" action="CampanaServlet">
                        <input type="hidden" name="action" value="filterlineaslist">
                        <tr>
                            <td width="151" height="32"><span class="texto">Departamento</span></td>
                            <td width="225"><label>

                                    <select name="busqueda_lineas" id="busqueda_lineas">
                                        <c:forEach var="departamentos" items="${requestScope.departamentos}">
                                            <option value ="${departamentos.idDepartamento}">${departamentos.descripcion}</option>
                                        </c:forEach>
                                    </select>

                                </label></td>
                            <td width="112"><span class="texto">Provincia</span></td>
                            <td width="211">
                                <select name="busqueda_lineas" id="busqueda_lineas">
                                        <c:forEach var="provincias" items="${requestScope.provincias}">
                                            <option value ="${provincias.idProvincia}">${provincias.descripcion}</option>
                                        </c:forEach>
                                </select>                            </td>
                            <td width="77"><label></label></td>
                        </tr>
                        <tr>
                            <td height="33"><span class="texto">Distrito</span></td>
                            <td height="33">
                                <select name="busqueda_lineas" id="busqueda_lineas">
                                        <c:forEach var="distritos" items="${requestScope.distritos}">
                                            <option value ="${distritos.idDistrito}">${distritos.descripcion}</option>
                                        </c:forEach>
                                </select>                            </td>
                            <td height="33"><span class="texto">Tipo de l&iacute;nea </span></td>
                            <td height="33">
                                <select name="busqueda_lineas" id="busqueda_lineas">
                                        <c:forEach var="tipolineas" items="${requestScope.tipolineas}">
                                            <option value ="${tipolineas.idTipoLinea}">${tipolineas.nombre}</option>
                                        </c:forEach>
                                </select>                            </td>
                            <td height="33"><input type="submit" name="Buscar" id="Buscar" value="Buscar"></td>
                        </tr>
                        <tr>
                            <td height="21" colspan="5">&nbsp;</td>
                        </tr>
                    </form>
                </table-->
                <div id="panelBusquedaLineas"></div>
                <form action="CampanaServlet">
                    <input type="hidden" name="action" value="guardarCampanaConLineas">
                    <input type="hidden" name="idCampana" id="idCampana" value="${idCampana}">
                    <input type="hidden" name="nombre" value="${nombre}">
                    <input type="hidden" name="mensaje" value="${mensaje}">
                    <input type="hidden" name="prioridad" value="${prioridad}">
                    <input type="hidden" name="empleado" value="${empleado}">
                    <input type="hidden" name="fecha1" value="${fecha1}">
                    <input type="hidden" name="fecha2" value="${fecha2}">
                    <input type="hidden" name="lineas" id="lineasHidden">



                    <%--table>
                        <tr>
                            <td width="1565">
                    <table width="1047" height="142" border="1" align="left">
                        <tr>
                            <td width="110" height="54"><div align="center" class="texto"><strong>IdL&iacute;nea</strong></div></td>
                            <td width="191"><div align="center" class="texto"><strong>N&uacute;mero</strong></div></td>
                            <td width="191"><div align="center" class="texto"><strong>Departamento</strong></div></td>
                            <td width="182"><div align="center" class="texto"><strong>Provincia</strong></div></td>
                            <td width="112"><div align="center" class="texto"><strong>Distrito</strong></div></td>
                            <td width="213"><div align="center" class="texto"><strong>Tipo de L&iacute;nea</strong></div></td>
                            <td width="199"><div align="center" class="texto"><strong>Seleccionar</strong></div></td>
                        </tr>
                        <c:forEach var="linea" items="${requestScope.lineas}">
                            <tr>
                                <td class="tablas">${linea.idLinea}</td>
                                <td class="tablas">${linea.numero}</td>
                                <td class="tablas">${linea.abonado.direccion.distrito.provincia.departamento.descripcion}</td>
                                <td class="tablas">${linea.abonado.direccion.distrito.provincia.descripcion}</td>
                                <td class="tablas">${linea.abonado.direccion.distrito.descripcion}</td>
                                <td class="tablas">${linea.tipoLinea.nombre}</td>
                                <c:if test="${linea.antigua}">
                                    <td><input type="checkbox" checked name="lineas" id="lineas" value="${linea.idLinea}"/></td>
                                </c:if>
                                <c:if test="${!linea.antigua}">
                                    <td><input type="checkbox" name="lineas" id="lineas" value="${linea.idLinea}"/></td>
                                </c:if>

                            </tr>
                        </c:forEach>
                    </table --%>
                    <table width="820" height="36" border="0" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="820" align="right"><input name="Buscar22" type="submit" id="Buscar22"  value="Agregar"></td>
                        </tr>
                        </table>
                    </form>
                          </td>
            </tr>
        </table>




    </TR>
    <TR>

      <TD  height="208" valign="top" bgcolor="#E4560B"><ul id="MenuBar1" class="MenuBarVertical">
        <li><a href="index2.jsp">Home</a>          </li>
        <li><a href="clientes2.jsp">Clientes</a></li>
        <li><a href="usuario2.jsp" class="MenuBarItemSubmenu">Administraci&oacute;n</a>
          <ul>
            <li><a href="AbonadoServlet">Abonados</a></li>
            <li><a href="CampanaServlet">Campa&ntilde;as</a></li>
            <li><a href="modificar_usuario.jsp">Empleados</a></li>
            <li><a href="ReportesServlet?action=listreportes">Reportes</a></li>
            <li><a href="CampanaServlet?action=volverusuario">Cerrar Sesi&oacute;n</a></li>
          </ul>
        </li>
        <li><a href="noticias2.jsp">Noticias</a></li>
        <li><a href="soporte2.jsp">Soporte</a></li>

        <li><a href="contactanos2.jsp">Cont&aacute;ctanos</a></li>
</ul></TD>
    </TR>
    <TR>
      <TD height="169" valign="top"><img src="images/info_area.jpg" alt="back" width=178 height=270></TD>
    </TR>
  </TABLE>
</div>
<!--Jansondesigns.com offers an impressive collection of professionally made web templates, banner templates,
flash designs, free templates and free web graphics. We have templates that suit any personal or professional web site needs!! -->

<script type="text/javascript">
<!--
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
//-->
</script>
</BODY>
</HTML>
